﻿using System;

namespace YBBIveelySe.Spider
{
    public class Engine
    {
        /// <summary>
        /// 根域名
        /// </summary>
        private static string Host { get; set; }

        /// <summary>
        /// 基本的爬行入口
        /// </summary>
        public Uri BaseUrl;

        /// <summary>
        /// 处理类型组
        /// </summary>
        private IProcessor[] _Processors;// = new {new HtmlHttpCrawlerContentProcessor()};

        /// <summary>
        /// 初始化类型组
        /// </summary>
        /// <param name="processors"></param>
        private void InitProcessors(params IProcessor[] processors)
        {
            _Processors = processors;
        }

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="baseUrl"></param>
        public Engine(string baseUrl)
        {
            //初始化入口URL
            this.BaseUrl = new Uri(baseUrl);
            //获取根域名
            Host = BaseUrl.Host.StartsWith("www.") ? BaseUrl.Host.Replace("www.", "") : BaseUrl.Host;
            //初始化处理类型
            this.InitProcessors(new HtmlProcessor());
        }

    }
}
